<?php

namespace App\Support;

use Illuminate\Support\Facades\Redis;

class Setting
{
    /**
     * 缓存设置
     *
     * @return void
     */
    public static function cache(){
        $config = \App\Models\Setting::all();
        Redis::pipeline(function ($pipe) use ($config) {
            foreach($config as $item){
                $pipe->set("setting:{$item->name}", $item->content);
            }
        });
    }

    /**
     * 获取设置
     *
     * @return string|null
     */
    public static function get($name){
        return Redis::get("setting:".$name);

    }


}